/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.informet.ipd.struts.action;


import com.informet.ipd.modelo.vo.*;
import com.informet.ipd.modelo.dao.*;
import com.informet.ipd.struts.form.PEIForm;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.JOptionPane;
import org.apache.commons.lang.StringUtils;


import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.chain.commands.servlet.SetContentType;

/**
 *
 * @author LYLA
 */
public class PEIAction extends DispatchAction {

    public ActionForward ingresarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int cod = 0;
        int idObj=form1.getIdObj();
        String desc = form1.getDescObj();
        OEstrategicoVO oEst = new OEstrategicoVO(cod,idObj,desc);
        new OEstrategicoDao().spMan(1, oEst);

        List listaObjetivo = new OEstrategicoDao().getlist();
        form1.setListaOEstrategico(listaObjetivo);
        return mapping.getInputForward();
    }

    public ActionForward ingresarOEspecifico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codObj = form1.getCodObj();
        int idObje = form1.getIdObje();
        int cod = 0;
        String desc = form1.getDescObjEsp();
        OEspecificoVO oEsp = new OEspecificoVO(cod, desc, codObj,idObje);
        new OEspecificoDao().spMan(1, oEsp);

        List listaObjetivo = new OEspecificoDao().getlist();
        form1.setListaOEspecifico(listaObjetivo);
        return mapping.getInputForward();
    }

    public ActionForward ingresarAPermanente(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codObj = form1.getCodObj();
        int idObje=form1.getIdObje();
        int cod = 0;
        String desc = form1.getDescObjEsp();
        OEspecificoVO oEsp = new OEspecificoVO(cod, desc, codObj,idObje);
        new OEspecificoDao().spMan(1, oEsp);

        List listaObjetivo = new OEspecificoDao().getlist();
        form1.setListaOEspecifico(listaObjetivo);
        return mapping.getInputForward();
    }

    public ActionForward eliminarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        PEIForm form1 = (PEIForm) form;
        int cod = Integer.parseInt(request.getParameter("codObj"));
        OEstrategicoVO oEst = new OEstrategicoDao().selectById(cod);
        form1.setCodObj(oEst.getNUM_CODOBJ_PK());
        form1.setDescObj(oEst.getTX_DESCOBJ());
        new OEstrategicoDao().spMan(3, oEst);
        List listaObjetivo = new OEstrategicoDao().getlist();
        form1.setListaOEstrategico(listaObjetivo);
        return mapping.getInputForward();

    }

    public ActionForward listarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        List listaObjetivo = new OEstrategicoDao().getlist();
        form1.setListaOEstrategico(listaObjetivo);
        return mapping.getInputForward();
    }

    public ActionForward listarOEspecifico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        form1.setCodObj(Integer.parseInt(request.getParameter("cod")));
        form1.setIdObj(Integer.parseInt(request.getParameter("idob")));
        form1.setDescObj(request.getParameter("desc"));
        List listaObjetivo = new OEspecificoDao().getListById(form1.getCodObj());
        form1.setListaOEspecifico(listaObjetivo);
        return mapping.findForward("especifico");
    }

    public ActionForward listarAPermanente(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        PEIForm form1 = (PEIForm) form;
        form1.setCodObjEsp(Integer.parseInt(request.getParameter("cod")));
        //&idObj="+idObj+"&idObje="+idObje;
        form1.setIdObj(Integer.parseInt(request.getParameter("idObj")));
        form1.setIdObje(Integer.parseInt(request.getParameter("idObje")));
        form1.setCodObj(Integer.parseInt(request.getParameter("codOGE")));
        form1.setDescObj(request.getParameter("codOEst"));
        form1.setDescObjEsp(request.getParameter("desc"));
        List listaDependencia = new DependenciaDao().getCombo();
        List listaResponsables = new APermanenteDao().getResponsables();
        List listaObjetivo = new APermanenteDao().getListById(form1.getCodObjEsp());
        form1.setListaActPer(listaObjetivo);
       
        form1.setListaDepen(listaDependencia);
        form1.setListaResponActPer(listaResponsables);
        return mapping.findForward("aPermanente");
    }

    public ActionForward listarMAPermanente(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        form1.setCodActPer(Integer.parseInt(request.getParameter("cod")));
        //form1.setCodActPerm(Integer.parseInt(request.getParameter("cod2")));
        form1.setDescActPer(request.getParameter("desc"));
        form1.setDescRespon(request.getParameter("resp"));
        form1.setDescObj(request.getParameter("descObj"));
        form1.setDescObjEsp(request.getParameter("descObjE"));

        List listaObjetivo = new MActividadDao().getListById(form1.getCodActPer());
        form1.setListaMetaAct(listaObjetivo);

        return mapping.findForward("mAPermanente");
    }

    //Meta Objetivo
    public ActionForward listarMetaO(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        int cod = Integer.parseInt(request.getParameter("codObj"));
        PEIForm form1 = (PEIForm) form;
        List listaMetaO = new MObjetivoDao().getlist(cod);
        form1.setListaMetaO(listaMetaO);
        form1.setCodObj(cod);
        form1.setIdObj(Integer.parseInt(request.getParameter("idob")));
        form1.setDescObj(request.getParameter("descObj"));
        return mapping.findForward("meta");
    }

    //Cuantificacion de Meta Objetivo
    public ActionForward listarCMObjetivo(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
         
        int codMetaO = Integer.parseInt(request.getParameter("codMetaO"));
       
        List listaCMObjetivo = new CMObjetivoDao().getlist(codMetaO);
        form1.setListacuMetaO(listaCMObjetivo);
        form1.setCodMetaO(codMetaO);
        form1.setDescMetaO(request.getParameter("descMetaO"));
        form1.setCodObj(Integer.parseInt(request.getParameter("codObj")));

        if (request.getParameter("tipoMetaO").equals("N")) {
            form1.setTipoMetaO("N");
        } else {
            form1.setTipoMetaO("%");
        }
        form1.setIdObj(Integer.parseInt(request.getParameter("idObj")));
        form1.setIdMetaO(Integer.parseInt(request.getParameter("idMetaO")));

       
        return mapping.findForward("cMObjetivo");
    }

    //Indicador
    public ActionForward listarIndicador(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;       
        int codMetaO = Integer.parseInt(request.getParameter("codMetaO"));
        List listaIndicador = new IndicadorDao().getlist(codMetaO);
        form1.setListaIndO(listaIndicador);
        form1.setCodMetaO(codMetaO);
        form1.setDescObj(request.getParameter("descObj"));
        form1.setDescMetaO(request.getParameter("descMetaO"));
        form1.setTipoMetaO(request.getParameter("tipoMetaO"));
        form1.setIdObj(Integer.parseInt(request.getParameter("idObj")));
        form1.setIdMetaO(Integer.parseInt(request.getParameter("idMetaO")));

        return mapping.findForward("indicador");
    }

    public ActionForward listarMedVerificacion(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codIndO = Integer.parseInt(request.getParameter("codIndO"));
        List listaMedVero = new MedVerificacionDao().getlist(codIndO);
        form1.setIdObj(Integer.parseInt(request.getParameter("idObj")));
        //form1.setIdMetaO(Integer.parseInt(request.getParameter("idMetaO")));
        //form1.setIdIndO(Integer.parseInt(request.getParameter("idIndO")));
        form1.setListaMedVero(listaMedVero);
        form1.setCodIndO(codIndO);
        form1.setDescIndO(request.getParameter("descIndO"));
        return mapping.findForward("medVerificacion");
    }

    public ActionForward listarTechoP(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;

        List listaObjetivo = new DependenciaDao().getlist();
        form1.setListaDepen(listaObjetivo);

        return mapping.findForward("presupuesto");
    }

    public ActionForward listarTechoPD(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;

        //DependenciaVO depen = new DependenciaVO(cod, desc, techo);
        //supportFacade.spMan(tipo, depen);
        //lista = supportFacade.getlist();
        //JOptionPane.showMessageDialog(null, "hola");


        
        HttpSession session = request.getSession();
        String dep=session.getAttribute("dependencia").toString();
        double presupuesto = new DependenciaDao().buscarpresupuesto(Integer.parseInt(dep));
        double total=new DependenciaDao().sumaM(Integer.parseInt(dep));

        form1.setPresupActPer(presupuesto);
        form1.setTotalpresdep(total);

        //List listaObjetivo = new DependenciaDao().getlist();
        //form1.setListaDepen(listaObjetivo);

        return mapping.findForward("presupuestod");
    }

    public ActionForward listarDemanda(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;

        List listaObjetivo = new OEstrategicoDao().getlist();
        List listaOEspecifico = new OEspecificoDao().getCombo(-1);
        List listaActPer = new APermanenteDao().getCombo(-1);
        form1.setListaOEstrategico(listaObjetivo);
        form1.setListaOEspecifico(listaOEspecifico);
        form1.setListaActPer(listaActPer);

        return mapping.findForward("demanda");
    }

    public List listaOEspecifico() throws SQLException {
        HttpServletRequest request = null;
        PEIForm form1 = new PEIForm();
        form1.setCodObj(Integer.parseInt(request.getParameter("codObj")));

        List listaOEspecifico = new OEspecificoDao().getCombo(form1.getCodObj());

        form1.setListaOEspecifico(listaOEspecifico);
        return form1.getListaOEspecifico();

    }

    public ActionForward listarMetaFisica(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        List listaObjetivo = new OEstrategicoDao().getlist();
        List listaObjetivoEspecifico = new OEspecificoDao().getCombo(-1);
        List listaActPerma = new APermanenteDao().getCombo(-1);
        List listaMActPerma = new MActividadDao().getCombo(-1);
        form1.setListaOEstrategico(listaObjetivo);
        form1.setListaOEspecifico(listaObjetivoEspecifico);
        form1.setListaActPer(listaActPerma);
        form1.setListaMetaAct(listaMActPerma);
        List listaMetaFisica = new FisiMetaDao().getlist();//por checkar
        //form1.setListaFisiMeta(listaMetaFisica);
        return mapping.findForward("MetaFisica");
    }

    public ActionForward listarPlanOperativo(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;


        List listaObjetivo = new OEstrategicoDao().getlist();

        Integer codObjEsp= StringUtils.isEmpty(request.getParameter("codObjEsp")) ? new Integer(-1)
                            : new Integer(request.getParameter("codObjEsp"));
        Integer codObj= StringUtils.isEmpty(request.getParameter("codObj")) ? new Integer(-1)
                            : new Integer(request.getParameter("codObj"));


        List listaObjetivoEspecifico = new OEspecificoDao().getCombo(codObjEsp);

        //Ini agregado
         String codObjEspBack= StringUtils.isEmpty(request.getParameter("codObjEspBack")) ? "-1"
                            : request.getParameter("codObjEspBack");
         String codObjBack= StringUtils.isEmpty(request.getParameter("codObjBack")) ? "-1"
                            : request.getParameter("codObjBack");

         String descObjEspBack= StringUtils.isEmpty(request.getParameter("descObjEspBack")) ? ""
                            : request.getParameter("descObjEspBack");
         String descObjBack= StringUtils.isEmpty(request.getParameter("descObjBack")) ? ""
                            : request.getParameter("descObjBack");
         form1.setCodObjBack(codObjBack);
         form1.setCodObjEspBack(codObjEspBack);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);

         listaObjetivoEspecifico = new OEspecificoDao().getCombo(new Integer(codObjBack));
        //Fin agregado


        form1.setListaOEstrategico(listaObjetivo);
        form1.setListaOEspecifico(listaObjetivoEspecifico);
       
            form1.setCodObj(codObj);
          
            form1.setCodObjEsp(codObjEsp);
           
            form1.setCodObj1(codObj.toString());
        //List listaActPermanente = new APermanenteDao().getlist2();
        //form1.setListaActPer(listaActPermanente);
        //List listaMetaFinanciera = new FinaMetaDao().getlist();
        //form1.setListaFinaMeta(listaMetaFinanciera);
        return mapping.findForward("PlanOperativo");
    }

    public ActionForward listarPlanOperativoModificado(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        List listaObjetivo = new OEstrategicoDao().getlist();
        List listaObjetivoEspecifico = new OEspecificoDao().getCombo(-1);
        
        //List listaActPermanente = new APermanenteDao().getlist2();
        //form1.setListaActPer(listaActPermanente);
        //List listaMetaFinanciera = new FinaMetaDao().getlist();
        //form1.setListaFinaMeta(listaMetaFinanciera);


         //Ini agregado
         String codObjEspBack= StringUtils.isEmpty(request.getParameter("codObjEspBack")) ? "-1"
                            : request.getParameter("codObjEspBack");
         String codObjBack= StringUtils.isEmpty(request.getParameter("codObjBack")) ? "-1"
                            : request.getParameter("codObjBack");

         String descObjEspBack= StringUtils.isEmpty(request.getParameter("descObjEspBack")) ? ""
                            : request.getParameter("descObjEspBack");
         String descObjBack= StringUtils.isEmpty(request.getParameter("descObjBack")) ? ""
                            : request.getParameter("descObjBack");
         form1.setCodObjBack(codObjBack);
         form1.setCodObjEspBack(codObjEspBack);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);

         listaObjetivoEspecifico = new OEspecificoDao().getCombo(new Integer(codObjBack));
        //Fin agregado

        form1.setListaOEstrategico(listaObjetivo);
        form1.setListaOEspecifico(listaObjetivoEspecifico);
        return mapping.findForward("PlanOperativoModificado");
    }

    public ActionForward ingresarMetaFisica(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codMAper = form1.getCodMetaAPer();
        int tipoFisiMeta = form1.getTipoFisimeta();
        double mes1 = form1.getMes1FisiMeta();
        double mes2 = form1.getMes2FisiMeta();
        double mes3 = form1.getMes3FisiMeta();
        double mes4 = form1.getMes4FisiMeta();
        double mes5 = form1.getMes5FisiMeta();
        double mes6 = form1.getMes6FisiMeta();
        double mes7 = form1.getMes7FisiMeta();
        double mes8 = form1.getMes8FisiMeta();
        double mes9 = form1.getMes9FisiMeta();
        double mes10 = form1.getMes10FisiMeta();
        double mes11 = form1.getMes11FisiMeta();
        double mes12 = form1.getMes12FisiMeta();
        int codFMet = form1.getCodFisiMeta();
        FisiMetaVO oFisMeta = new FisiMetaVO(codFMet, codMAper, tipoFisiMeta, mes1, mes2, mes3, mes4, mes5, mes6, mes7, mes8, mes9, mes10, mes11, mes12);
        new FisiMetaDao().spMan(1, oFisMeta);
        List listaFisiMeta = new FisiMetaDao().getFiltro(codMAper);
        form1.setListaFisiMeta(listaFisiMeta);
        return mapping.getInputForward();
    }

    public ActionForward consultarMetaFisica(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codMAper = form1.getCodMetaAPer();
        int tipoFisiMeta = form1.getTipoFisimeta();
        double mes1 = form1.getMes1FisiMeta();
        double mes2 = form1.getMes2FisiMeta();
        double mes3 = form1.getMes3FisiMeta();
        double mes4 = form1.getMes4FisiMeta();
        double mes5 = form1.getMes5FisiMeta();
        double mes6 = form1.getMes6FisiMeta();
        double mes7 = form1.getMes7FisiMeta();
        double mes8 = form1.getMes8FisiMeta();
        double mes9 = form1.getMes9FisiMeta();
        double mes10 = form1.getMes10FisiMeta();
        double mes11 = form1.getMes11FisiMeta();
        double mes12 = form1.getMes12FisiMeta();
        int codFMet = 0;
        FisiMetaVO oFisMeta = new FisiMetaVO(codFMet, codMAper, tipoFisiMeta, mes1, mes2, mes3, mes4, mes5, mes6, mes7, mes8, mes9, mes10, mes11, mes12);
        new FisiMetaDao().spMan(1, oFisMeta);
        List listaFisiMeta = new FisiMetaDao().getlist();
        form1.setListaFisiMeta(listaFisiMeta);
        return mapping.getInputForward();
    }

    public ActionForward listarMetaFinanciera(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        List listaObjetivo = new OEstrategicoDao().getlist();
        List listaObjetivoEspecifico = new OEspecificoDao().getCombo(-1);
        List listaActPerma = new APermanenteDao().getCombo(-1);
        form1.setListaOEstrategico(listaObjetivo);
        form1.setListaOEspecifico(listaObjetivoEspecifico);
        form1.setListaActPer(listaActPerma);
        //List listaMetaFinanciera = new FinaMetaDao().getlist();
        //form1.setListaFinaMeta(listaMetaFinanciera);
        return mapping.findForward("MetaFinanciera");
    }

    public ActionForward ingresarMetaFinanciera(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codAPer = form1.getCodActPer();
        double mes1 = form1.getMes1FinaMeta();
        double mes2 = form1.getMes2FinaMeta();
        double mes3 = form1.getMes3FinaMeta();
        double mes4 = form1.getMes4FinaMeta();
        double mes5 = form1.getMes5FinaMeta();
        double mes6 = form1.getMes6FinaMeta();
        double mes7 = form1.getMes7FinaMeta();
        double mes8 = form1.getMes8FinaMeta();
        double mes9 = form1.getMes9FinaMeta();
        double mes10 = form1.getMes10FinaMeta();
        double mes11 = form1.getMes11FinaMeta();
        double mes12 = form1.getMes12FinaMeta();
        int codFMet = 0;
        FinaMetaVO oFinaMeta = new FinaMetaVO(codFMet, codAPer, mes1, mes2, mes3, mes4, mes5, mes6, mes7, mes8, mes9, mes10, mes11, mes12);
        new FinaMetaDao().spMan(1, oFinaMeta);
        List listaFinaMeta = new FinaMetaDao().getFiltro(codAPer);
        form1.setListaFinaMeta(listaFinaMeta);
        return mapping.getInputForward();
    }

    public ActionForward listarTareaActividad(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
       
        String idActividad = request.getParameter("idActividad");

        String descOEstrategico = request.getParameter("descOEstrategico");
        String descOEspecifico = request.getParameter("descOEspecifico");
        String descActividad = request.getParameter("descActividad");
        double presupuesto = Double.parseDouble(request.getParameter("ppto"));
        String iniciomes = request.getParameter("inimes");
        String finmes = request.getParameter("finmes");

        int dependencia=1;
        double suma=new TActividadDao().sumaM(dependencia, (Integer.parseInt(idActividad)));
        //Ini agregado
             String codObj=request.getParameter("codObjBack");
             String codObjEsp=request.getParameter("codObjEspBack");
             String descObj=request.getParameter("descObjBack");
             String descObjEs=request.getParameter("descObjEspBack");
             form1.setCodObjBack(codObj);
             form1.setCodObjEspBack(codObjEsp);

             form1.setDescObjBack(descObj);
             form1.setDescObjEspBack(descObjEs);
       //Fin agregado
        form1.setDescObj(descOEstrategico);
        form1.setDescObjEsp(descOEspecifico);
        form1.setDescActPer(descActividad);
        form1.setCodTActividad(Integer.parseInt(idActividad));
        form1.setPresupActPer(presupuesto);
        form1.setFinicio(iniciomes);
        form1.setTotalpresdep(suma);
        form1.setFfin(finmes);
        return mapping.findForward("tareaActividad");
    }

    public ActionForward listarTareaActividadM(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
       
        String idActividad = request.getParameter("idActividad");
       
        String descOEstrategico = request.getParameter("descOEstrategico");
        String descOEspecifico = request.getParameter("descOEspecifico");
        String descActividad = request.getParameter("descActividad");
        double presupuesto = Double.parseDouble(request.getParameter("ppto"));
        String iniciomes = request.getParameter("inimes");
        String finmes = request.getParameter("finmes");
        form1.setDescObj(descOEstrategico);
        form1.setDescObjEsp(descOEspecifico);
        form1.setDescActPer(descActividad);
        form1.setCodTActividad(Integer.parseInt(idActividad));
        form1.setPresupActPer(presupuesto);
        form1.setFinicio(iniciomes);
        form1.setFfin(finmes);
//        List listaObjetivo = new OEstrategicoDao().getlist();
//        List listaObjetivoEspecifico = new OEspecificoDao().getCombo(-1);
//        List listaActPerma = new APermanenteDao().getCombo(-1);
//        form1.setListaOEstrategico(listaObjetivo);
//        form1.setListaOEspecifico(listaObjetivoEspecifico);
//        form1.setListaActPer(listaActPerma);
//        List listaTActividad = new TActividadDao().getlist();
//        form1.setListaTActividad(listaTActividad);
        //Ini agregado
         String codObjEspBack= StringUtils.isEmpty(request.getParameter("codObjEspBack")) ? "-1"
                            : request.getParameter("codObjEspBack");
         String codObjBack= StringUtils.isEmpty(request.getParameter("codObjBack")) ? "-1"
                            : request.getParameter("codObjBack");

         String descObjEspBack= StringUtils.isEmpty(request.getParameter("descObjEspBack")) ? ""
                            : request.getParameter("descObjEspBack");
         String descObjBack= StringUtils.isEmpty(request.getParameter("descObjBack")) ? ""
                            : request.getParameter("descObjBack");
         form1.setCodObjBack(codObjBack);
         form1.setCodObjEspBack(codObjEspBack);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);
//Fin agregado
        return mapping.findForward("tareaActividadM");
    }

    public ActionForward listarMetaTarea(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int pk = Integer.parseInt(request.getParameter("pk"));
        String tarea = request.getParameter("tarea");
        String um = request.getParameter("um");
        int tipoN = Integer.parseInt(request.getParameter("tipoN"));
        String tipoNString="";
        if(tipoN==1){
            tipoNString="N";
        }
        if(tipoN==2){
            tipoNString="%";
        }
        String descObj = request.getParameter("descObj");

        String descObjEsp = request.getParameter("descObjEsp");
        String descActPer = request.getParameter("descActPer");
        int iniciomes = Integer.parseInt(request.getParameter("inimes"));
        int finmes = Integer.parseInt(request.getParameter("finmes"));
        int cantTA = Integer.parseInt(request.getParameter("cantTA"));
        int flag=new MATareaDao().getMuestramatarea(pk);
        


//            HttpSession session=request.getSession();
//            session.setAttribute("fkAct", codTarea);
        form1.setDescObj(descObj);
        form1.setDescObjEsp(descObjEsp);
        form1.setCodTActividad(pk);
        form1.setDescTActividad(tarea);
        form1.setUmTActividad(um);
        form1.setTarea1TActividadS(tipoNString);
        form1.setDescActPer(descActPer);
        form1.setInicio(iniciomes);
        form1.setCodActPer(Integer.parseInt(request.getParameter("idActividad")));
      
        form1.setFin(finmes);
        form1.setNumTActividad(cantTA);
        form1.setFlag(flag);

        //Ini agregado
             String codObj=request.getParameter("codObjBack");
             String codObjEsp=request.getParameter("codObjEspBack");
             String descObjBack=request.getParameter("descObjBack");
             String descObjEs=request.getParameter("descObjEspBack");
             form1.setCodObjBack(codObj);
             form1.setCodObjEspBack(codObjEsp);

             form1.setDescObjBack(descObjBack);
             form1.setDescObjEspBack(descObjEs);
       //Fin agregado

        return mapping.findForward("metaATarea");
    }

    public ActionForward listarMetaTareaM(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int pk = Integer.parseInt(request.getParameter("pk"));
        String tarea = request.getParameter("tarea");
        String um = request.getParameter("um");
        int tipoN = Integer.parseInt(request.getParameter("tipoN"));
        int cantTA = Integer.parseInt(request.getParameter("cantTA"));
        String tipoNString="";
        if(tipoN==1){
            tipoNString="N";
        }
        if(tipoN==2){
            tipoNString="%";
        }

        String descObj = request.getParameter("descObj");
        String descObjEsp = request.getParameter("descObjEsp");
        String descActPer = request.getParameter("descActPer");
        int iniciomes = Integer.parseInt(request.getParameter("inimes"));
        int finmes = Integer.parseInt(request.getParameter("finmes"));
        int flag=new MATareaDao().getMuestramatareaMod(pk);

//            HttpSession session=request.getSession();
//            session.setAttribute("fkAct", codTarea);

//Ini agregado
         String codObjEspBack= StringUtils.isEmpty(request.getParameter("codObjEspBack")) ? "-1"
                            : request.getParameter("codObjEspBack");
         String codObjBack= StringUtils.isEmpty(request.getParameter("codObjBack")) ? "-1"
                            : request.getParameter("codObjBack");

         String descObjEspBack= StringUtils.isEmpty(request.getParameter("descObjEspBack")) ? ""
                            : request.getParameter("descObjEspBack");
         String descObjBack= StringUtils.isEmpty(request.getParameter("descObjBack")) ? ""
                            : request.getParameter("descObjBack");
         form1.setCodObjBack(codObjBack);
         form1.setCodObjEspBack(codObjEspBack);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);
//Fin agregado
         
        form1.setDescObj(descObj);
        form1.setDescObjEsp(descObjEsp);
        form1.setCodTActividad(pk);
        form1.setDescTActividad(tarea);
        form1.setUmTActividad(um);
        form1.setTarea1TActividadS(tipoNString);
        form1.setDescActPer(descActPer);
        form1.setInicio(iniciomes);
        form1.setFin(finmes);
        form1.setNumTActividad(cantTA);
        form1.setCodActPer(Integer.parseInt(request.getParameter("idActividad")));
        form1.setFlag(flag);
        return mapping.findForward("metaATareaM");
    }

    public ActionForward listarMFisica(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codA = Integer.parseInt(request.getParameter("codA"));
        int codMA = Integer.parseInt(request.getParameter("codMA"));
        //JOptionPane.showMessageDialog(null, codMA);
        int cantA = Integer.parseInt(request.getParameter("cantA"));
        String umA = request.getParameter("umA");
        String tipoA = request.getParameter("tipoA");
        String descObj = request.getParameter("codObj");
        String descObjEs = request.getParameter("codObjEsp");
        String descA = request.getParameter("descA");
        int iniciomes = Integer.parseInt(request.getParameter("inimes"));
        int finmes = Integer.parseInt(request.getParameter("finmes"));
        int coe=Integer.parseInt(request.getParameter("coe"));
        int idObj=Integer.parseInt(request.getParameter("idObj"));
        HttpSession session = request.getSession();
        session.setAttribute("fkAct", codA);

        List listaFisiMeta = new FisiMetaDao().getFiltro(codMA);
        int flag=(new FisiMetaDao()).getMuestrafin(codMA);
        form1.setListaFisiMeta(listaFisiMeta);

        //Ini agregado
        //codObjBack,codObjEspBack,descObjBack,descObjEspBack
         String codObj=request.getParameter("codObjBack");
         String codObjEsp=request.getParameter("codObjEspBack");
         descObj=request.getParameter("descObjBack");
         descObjEs=request.getParameter("descObjEspBack");
         form1.setCodObjBack(codObj);
         form1.setCodObjEspBack(codObjEsp);
        //Fin agregado
        form1.setCodMetaAper(codMA);
        form1.setDescObj(descObj);
        form1.setCodObj(idObj);
        form1.setDescObjEsp(descObjEs);
        form1.setCodObjEsp(coe);
        form1.setCantActPer(cantA);
        form1.setTipoActPer(tipoA);
        form1.setUmActPer(umA);
        form1.setDescActPer(descA);
        form1.setInicio(iniciomes);
        form1.setFin(finmes);
        form1.setFlag(flag);
        //form1.setFlag(1);
        return mapping.findForward("MetaFisica");
    }

    public ActionForward listarMFisicaM(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codA = Integer.parseInt(request.getParameter("codA"));
        int codMA = Integer.parseInt(request.getParameter("codMA"));
        int cantA = Integer.parseInt(request.getParameter("cantA"));
        int iniciomes = Integer.parseInt(request.getParameter("inimes"));
        int finmes = Integer.parseInt(request.getParameter("finmes"));
        String umA = request.getParameter("umA");
        String tipoA = request.getParameter("tipoA");
        String descObj = request.getParameter("codObj");
        String descObjEs = request.getParameter("codObjEsp");
        String descA = request.getParameter("descA");
        int flag=new FisiMetaDao().getMuestrafinMod(codMA);
        HttpSession session = request.getSession();
        session.setAttribute("fkAct", codA);
        List listaFisiMeta = new FisiMetaDao().getFiltroM(codMA);
        form1.setListaFisiMeta(listaFisiMeta);

        form1.setInicio(iniciomes);
        form1.setFin(finmes);

         //Ini agregado
        //codObjBack,codObjEspBack,descObjBack,descObjEspBack
         String codObj=request.getParameter("codObjBack");
         String codObjEsp=request.getParameter("codObjEspBack");
         String descObjBack=request.getParameter("descObjBack");
         String descObjEspBack=request.getParameter("descObjEspBack");
         form1.setCodObjBack(codObj);
         form1.setCodObjEspBack(codObjEsp);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);
        //Fin agregado

        form1.setCodMetaAper(codMA);
        form1.setDescObj(descObj);
        form1.setDescObjEsp(descObjEs);
        form1.setCantActPer(cantA);
        form1.setTipoActPer(tipoA);
        form1.setUmActPer(umA);
        form1.setDescActPer(descA);
        form1.setFlag(flag);



        return mapping.findForward("MetaFisicaM");
    }

      
      
      public ActionForward listarMFinanciera(ActionMapping mapping, ActionForm form,
              HttpServletRequest request, HttpServletResponse response)
              throws Exception {
              PEIForm form1 = (PEIForm) form;
              int codA=Integer.parseInt(request.getParameter("codA"));
              //JOptionPane.showMessageDialog(null, "codA->"+codA);
              String  descObj=request.getParameter("codObj");
              //JOptionPane.showMessageDialog(null, "codObj->"+descObj);
              String  descObjEs=request.getParameter("codObjEsp");
              double total=Double.parseDouble(request.getParameter("tot"));
              String  descA=request.getParameter("descA");
              int iniciomes = Integer.parseInt(request.getParameter("inimes"));
              int finmes = Integer.parseInt(request.getParameter("finmes"));
              int flag=new FinaMetaDao().getMuestrafin(codA);
              form1.setCodActPer(codA);
              form1.setDescObj(descObj);
              form1.setDescObjEsp(descObjEs);
              form1.setTotal(total);
              form1.setDescActPer(descA);
              List lista = new FinaMetaDao().getFiltro(codA);
              form1.setListaFinaMeta(lista);
              form1.setInicio(iniciomes);

            //Ini agregado
             String codObj=request.getParameter("codObjBack");
             String codObjEsp=request.getParameter("codObjEspBack");
             descObj=request.getParameter("descObjBack");
             descObjEs=request.getParameter("descObjEspBack");
             form1.setCodObjBack(codObj);
             form1.setCodObjEspBack(codObjEsp);
             
             form1.setDescObjBack(descObj);
             form1.setDescObjEspBack(descObjEs);
            //Fin agregado
             
        form1.setFin(finmes);
        form1.setFlag(flag);
              return mapping.findForward("MetaFinanciera");


      }


    public ActionForward listarMFinancieraM(ActionMapping mapping, ActionForm form,
              HttpServletRequest request, HttpServletResponse response)
              throws Exception {
              PEIForm form1 = (PEIForm) form;
              int codA=Integer.parseInt(request.getParameter("codA"));
              //JOptionPane.showMessageDialog(null, "codA->"+codA);
              String  descObj=request.getParameter("codObj");
              //JOptionPane.showMessageDialog(null, "codObj->"+descObj);
              String  descObjEs=request.getParameter("codObjEsp");
              String  descA=request.getParameter("descA");
              double total=Double.parseDouble(request.getParameter("tot"));
              int iniciomes = Integer.parseInt(request.getParameter("inimes"));
              int finmes = Integer.parseInt(request.getParameter("finmes"));
              int flag=new FinaMetaDao().getMuestrafinMod(codA);
              form1.setCodActPer(codA);
              form1.setDescObj(descObj);
              form1.setDescObjEsp(descObjEs);
              form1.setTotal(total);
              form1.setDescActPer(descA);
              form1.setInicio(iniciomes);
        form1.setFin(finmes);
        form1.setFlag(flag);
              List lista = new FinaMetaDao().getFiltroM(codA);
              form1.setListaFinaMeta(lista);

    //Ini agregado
         String codObjEspBack= StringUtils.isEmpty(request.getParameter("codObjEspBack")) ? "-1"
                            : request.getParameter("codObjEspBack");
         String codObjBack= StringUtils.isEmpty(request.getParameter("codObjBack")) ? "-1"
                            : request.getParameter("codObjBack");

         String descObjEspBack= StringUtils.isEmpty(request.getParameter("descObjEspBack")) ? ""
                            : request.getParameter("descObjEspBack");
         String descObjBack= StringUtils.isEmpty(request.getParameter("descObjBack")) ? ""
                            : request.getParameter("descObjBack");
         form1.setCodObjBack(codObjBack);
         form1.setCodObjEspBack(codObjEspBack);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);
    //Fin agregado

              return mapping.findForward("MetaFinancieraM");
      }
      
      
      
      public ActionForward listarTActividad(ActionMapping mapping, ActionForm form,
              HttpServletRequest request, HttpServletResponse response)
              throws Exception {
              PEIForm form1 = (PEIForm) form;
              int codA=Integer.parseInt(request.getParameter("codA"));
              String  descObj=request.getParameter("codObj");
              String  descObjEs=request.getParameter("codObjEsp");
              //implementar set y mas
              return mapping.findForward("TareaActividad");
      }


  

    public ActionForward listarTActividadM(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int codA = Integer.parseInt(request.getParameter("codA"));
        String descObj = request.getParameter("codObj");
        String descObjEs = request.getParameter("codObjEsp");
        //implementar set y mas
        return mapping.findForward("TareaActividadM");
    }

    public ActionForward listarPPTO(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int pk = Integer.parseInt(request.getParameter("pk"));
        String tarea = request.getParameter("tarea");
        String descObj = request.getParameter("descObj");
        String descObjEsp = request.getParameter("descObjEsp");
        String descActPer = request.getParameter("descActPer");
        double ppto = Double.parseDouble(request.getParameter("ppto"));
        int iniciomes = Integer.parseInt(request.getParameter("inimes"));
        int finmes = Integer.parseInt(request.getParameter("finmes"));
        int flag=new PTareaActDao().getMuestrapTarea(pk);
        form1.setDescObj(descObj);
        form1.setDescObjEsp(descObjEsp);
        form1.setCodTActividad(pk);
        form1.setDescTActividad(tarea);
        form1.setDescActPer(descActPer);
        form1.setPpto(ppto);
        form1.setCodActPer(Integer.parseInt(request.getParameter("idActividad")));

        //Ini agregado
             String codObj=request.getParameter("codObjBack");
             String codObjEsp=request.getParameter("codObjEspBack");
             descObj=request.getParameter("descObjBack");
             String descObjEs=request.getParameter("descObjEspBack");
             form1.setCodObjBack(codObj);
             form1.setCodObjEspBack(codObjEsp);

             form1.setDescObjBack(descObj);
             form1.setDescObjEspBack(descObjEs);
         //Fin agregado

        form1.setInicio(iniciomes);
        form1.setFin(finmes);
        form1.setFlag(flag);
        return mapping.findForward("pptoTarea");
    }

    public ActionForward listarPPTOM(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        int pk = Integer.parseInt(request.getParameter("pk"));
        String tarea = request.getParameter("tarea");
        String descObj = request.getParameter("descObj");
        String descObjEsp = request.getParameter("descObjEsp");
        String descActPer = request.getParameter("descActPer");
        double ppto = Double.parseDouble(request.getParameter("ppto"));
        int iniciomes = Integer.parseInt(request.getParameter("inimes"));
        int finmes = Integer.parseInt(request.getParameter("finmes"));
        int flag=new PTareaActDao().getMuestrapTarea(pk);

//            HttpSession session=request.getSession();
//            session.setAttribute("fkAct", codTarea);
        form1.setDescObj(descObj);
        form1.setDescObjEsp(descObjEsp);
        form1.setCodTActividad(pk);
        form1.setDescTActividad(tarea);
        form1.setDescActPer(descActPer);
        form1.setPpto(ppto);
        form1.setCodActPer(Integer.parseInt(request.getParameter("idActividad")));
        form1.setInicio(iniciomes);
        form1.setFin(finmes);
        form1.setFlag(flag);
        //Ini agregado
         String codObjEspBack= StringUtils.isEmpty(request.getParameter("codObjEspBack")) ? "-1"
                            : request.getParameter("codObjEspBack");
         String codObjBack= StringUtils.isEmpty(request.getParameter("codObjBack")) ? "-1"
                            : request.getParameter("codObjBack");

         String descObjEspBack= StringUtils.isEmpty(request.getParameter("descObjEspBack")) ? ""
                            : request.getParameter("descObjEspBack");
         String descObjBack= StringUtils.isEmpty(request.getParameter("descObjBack")) ? ""
                            : request.getParameter("descObjBack");
         form1.setCodObjBack(codObjBack);
         form1.setCodObjEspBack(codObjEspBack);
         form1.setDescObjBack(descObjBack);
         form1.setDescObjEspBack(descObjEspBack);
//Fin agregado
         
        return mapping.findForward("pptoTareaM");
    }

    public ActionForward pEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        PEIForm form1 = (PEIForm) form;
        List listaObjetivo = new OEstrategicoDao().getlist();
        List listaObjetivoEspecifico = new OEspecificoDao().getCombo(-1);
        List listaActPerma = new APermanenteDao().getCombo(-1);
        form1.setListaOEstrategico(listaObjetivo);
        form1.setListaOEspecifico(listaObjetivoEspecifico);
        form1.setListaActPer(listaActPerma);


        return mapping.findForward("pEstrategicos");
    }
}
